<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2020/5/19
  Time: 11:44
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<% String path = request.getContextPath();%>
<script type="text/javascript" src="${pageContext.request.contextPath}/static/js/jquery-3.5.1.min.js"></script>
<jsp:include page="/manage/inc/header"/>
<jsp:include page="/manage/inc/menu"/>
    <!--/sidebar-->
    <div class="main-wrap">

        <div class="crumb-wrap">
            <div class="crumb-list"><i class="icon-font"></i><a href="<%=path%>/manage/index.jsp">首页</a><span class="crumb-step">&gt;</span><span class="crumb-name">类型管理</span></div>
        </div>
        <div class="search-wrap">
            <div class="search-content">
                <form action="#" method="post">
                    <table class="search-tab">
                        <tr>
                            <th width="120">城市查找:</th>
                            <td>
                                <select  id="city" name="search-sort">
                                    <option value="">全部</option>
                                    <c:forEach items="${cityList}" var="city">
                                        <option value="${city.id}">${city.cityName}</option>
                                    </c:forEach>
                                </select>
                            </td>
                            <th width="120">行业查找:</th>
                            <td>
                                <select name="search-sort" id="industryId">
                                    <option value="">全部</option>
                                    <c:forEach items="${industryList}" var="industry">
                                        <option value="${industry.id}">${industry.industryName}</option>
                                    </c:forEach>
                                </select>
                            </td>
                            <th width="120">发展阶段:</th>
                            <td>
                                <select name="search-sort" id="stageId">
                                    <option value="">全部</option>
                                    <c:forEach items="${stageList}" var="stage">
                                        <option value="${stage.id}">${stage.stageName}</option>
                                    </c:forEach>
                                </select>
                            </td>
                            <th width="70">公司名:</th>
                            <td><input class="common-text" placeholder="关键字" name="companyName" value="" id="companyName" type="text"></td>
                            <td><input class="btn btn-primary btn2" name="sub" id="search" value="查询" type="button"></td>
                        </tr>
                    </table>
                </form>
            </div>
        </div>
        <div class="result-wrap">

<%--            <div class="result-title">--%>
<%--                <div class="result-list">--%>
<%--                    <a id="batchDel" href="javascript:void(0)"><i class="icon-font"></i>批量删除</a>--%>
<%--                </div>--%>
<%--            </div>--%>
                <div class="result-content">

                </div>

        </div>
    </div>
    <!--/main-->
</div>
<jsp:include page="/manage/inc/footer"/>

<script>
    var  path="${pageContext.request.contextPath}"
    $(function () {
        var pageNum=1;
        var cityId=null;
        var industryId=null;
        var stageId=null;
        var companyName=null;
        initData(pageNum,cityId,industryId,stageId,companyName);

        //点击搜索按钮
        $("#search").click(function () {
            cityId=$("#city").val();
            industryId=$("#industryId").val();
            stageId=$("#stageId").val();
            companyName=$("#companyName").val();
            initData(pageNum,cityId,industryId,stageId,companyName);

        });
        //实现复选框的全选
        $(".result-content").on("click",".allChoose",function () {
            $(":checkbox[id^='choose']").prop("checked",$(this).prop("checked"));


        })
       $(".result-content").on("click",".authable",function () {
           var id=$(this).data("id");
           $.get(path+"/manage/company/updateHot",{id:id},function () {
               if($(this).find("img").length==1)
               {
                   $(this).html("");
               }
               else
               {
                   $(this).html("<img src=\"${pageContext.request.contextPath}/static/manageimages/onCorrect.gif\"/>");
               }
           }.bind(this));

       })
        $(".result-content").on("click",".opened",function () {
            var id=$(this).data("id");
            $.get(path+"/manage/company/updateOpened",{id:id},function () {
                if($(this).find("img").length==1)
                {
                    $(this).html("");
                }
                else
                {
                    $(this).html("<img src=\"${pageContext.request.contextPath}/static/manageimages/onCorrect.gif\"/>");
                }
            }.bind(this));

        })
        //删除
        $(".result-content").on("click",".link-del",function () {
            var id=$(this).data("id");
            var that=this;
            $.get({
                url:path+"/manage/company/delete",
                data:{id:id},
                success:function () {
                    $(this).parent().parent().remove();

                }.bind(this)

            })

        })

        //点击页码
        $(".result-content").on("click",".list-page a",function () {
            var pageNum=$(this).data("pagenum");
            cityId=$("#city").val();
            industryId=$("#industryId").val();
            stageId=$("#stageId").val();
            companyName=$("#companyName").val();
            if(cityId=="") cityId=null;
            if(industryId=="") industryId=null;
            if(stageId=="") stageId=null;
            if(companyName=="") companyName=null;
            initData(pageNum,cityId,industryId,stageId,companyName);
            return false;
        });

    });

    function initData(pageNum,cityId,industryId,stageId,companyName) {
        $.ajax({
            url:"listdata",
            data:{pageNum:pageNum,cityId:cityId,industryId:industryId,stageId:stageId,companyName:companyName},
            success:function (result) {
                $(".result-content").html(result);
            }
        });
    }
</script>
